﻿//浮动显示二级子目录js
function GetScrollXY(){
    var x=0,y=0
    if(document.documentElement.scrollTop){
        x=document.documentElement.scrollLeft;
        y=document.documentElement.scrollTop;
    }
    else{
        x=document.body.scrollLeft;
        y=document.body.scrollTop;
    }
    return {
        x:x,
        y:y
    }
}

window._stopMouseOver=function(e){
    (window.event||e).cancelBubble=true;
}

function showUserCard(e, url)
{
    e = (window.event||e); e.cancelBubble=true;
    var img = e.srcElement || e.target;
    if(!url) return;
    var layer=document.getElementById("UserCard_layer");
    if(!layer)
        return;
    layer.style.display="";
    var xy;
    if(navigator.userAgent.toLowerCase().indexOf("opera")<0)
    {
        xy=realOffset(img); layer.style.left = (xy.x+img.offsetWidth-2) +"px";
    }
    else//is opera
    {
        xy=getEventXY(e); layer.style.left = xy.x +"px";
    }
    layer.style.top  = (xy.y) +"px";

	$("#UserCard_layer_body").load(url);
}

document.attachEvent("onmouseover", function(){
    try{
        document.getElementById("UserCard_layer").style.display="none";
    }catch(ex){}
    });

function getEventXY(e){
    var posx=0,posy=0;
    if(e==null) e=window.event;
    if(e.pageX || e.pageY)
    {
        posx=e.pageX; posy=e.pageY;
    }
    else if(e.clientX || e.clientY)
    {
        posx=e.clientX+GetScrollXY().x;
        posy=e.clientY+GetScrollXY().y;
    }
    return {
        "x":posx,
        "y":posy
    };
}

function realOffset(o)
{
    if(!o) return null; var e=o, x=y=l=t=0;
    do{
        l+=e.offsetLeft||0; t+=e.offsetTop||0; e=e.offsetParent;
    }while(e);
    do{
        x+=o.scrollLeft||0; y+=o.scrollTop||0; o=o.parentNode;
    }while(o);
    var xy=GetScrollXY();
    return {
        "x":l-x+xy.x,
        "y":t-y+xy.y
        };
};
